<script setup>
import { ref } from 'vue'

// 模拟博客文章数据
const articles = ref([
  {
    id: 1,
    title: 'Vue3 Composition API 实战指南',
    excerpt: '探索Vue3 Composition API的强大功能和最佳实践...',
    date: '2024-01-15',
    author: '技术博主',
    category: '前端开发'
  },
  {
    id: 2,
    title: 'Vite性能优化技巧总结',
    excerpt: '如何让你的Vite项目构建更快，加载更高效...',
    date: '2024-01-10',
    author: '前端专家',
    category: '工程化'
  },
  {
    id: 3,
    title: '响应式设计的现代实践',
    excerpt: '打造完美适配各种设备的响应式网站...',
    date: '2024-01-05',
    author: 'UI设计师',
    category: '设计'
  }
])
</script>

<template>
  <div class="blog-container">
    <!-- 导航栏 -->
    <header class="navbar">
      <div class="container">
        <h1 class="logo">我的博客</h1>
        <nav>
          <ul class="nav-links">
            <li><router-link to="/">首页</router-link></li>
            <li><a href="#">分类</a></li>
            <li><a href="#">标签</a></li>
            <li><a href="#">关于</a></li>
          </ul>
        </nav>
      </div>
    </header>

    <!-- 主内容区 -->
    <main class="container">
      <div class="content">
        <h2 class="section-title">最新文章</h2>
        <div class="article-list">
          <article v-for="article in articles" :key="article.id" class="article-card">
            <div class="article-header">
              <h3 class="article-title">{{ article.title }}</h3>
              <div class="article-meta">
                <span class="author">{{ article.author }}</span>
                <span class="date">{{ article.date }}</span>
                <span class="category">{{ article.category }}</span>
              </div>
            </div>
            <p class="article-excerpt">{{ article.excerpt }}</p>
            <router-link :to="`/article/${article.id}`" class="read-more">阅读全文</router-link>
          </article>
        </div>
      </div>

      <!-- 侧边栏 -->
      <aside class="sidebar">
        <div class="sidebar-section">
          <h3>搜索</h3>
          <div class="search-box">
            <input type="text" placeholder="搜索文章..." />
            <button>搜索</button>
          </div>
        </div>
        
        <div class="sidebar-section">
          <h3>分类</h3>
          <ul class="category-list">
            <li><a href="#">前端开发</a></li>
            <li><a href="#">工程化</a></li>
            <li><a href="#">设计</a></li>
            <li><a href="#">工具</a></li>
          </ul>
        </div>

        <div class="sidebar-section">
          <h3>热门标签</h3>
          <div class="tags">
            <a href="#">Vue3</a>
            <a href="#">Vite</a>
            <a href="#">JavaScript</a>
            <a href="#">CSS</a>
            <a href="#">响应式</a>
          </div>
        </div>
      </aside>
    </main>

    <!-- 页脚 -->
    <footer class="footer">
      <div class="container">
        <p>&copy; 2024 我的博客. All rights reserved.</p>
        <div class="social-links">
          <a href="#">GitHub</a>
          <a href="#">Twitter</a>
          <a href="#">LinkedIn</a>
        </div>
      </div>
    </footer>
  </div>
</template>

<style scoped>
.blog-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.navbar {
  background-color: var(--secondary-color);
  color: white;
  padding: 1rem 0;
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  margin: 0;
}

.nav-links {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links li {
  margin-left: 1.5rem;
}

.nav-links a,
.nav-links router-link {
  color: white;
  text-decoration: none;
  transition: var(--transition);
}

.nav-links a:hover,
.nav-links router-link:hover {
  color: var(--primary-color);
  text-decoration: none;
}

.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

main {
  display: flex;
  flex: 1;
  margin: 2rem 0;
  gap: 2rem;
}

.content {
  flex: 1;
}

.section-title {
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
  color: var(--text-color);
}

.article-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.article-card {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.article-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.article-title {
  font-size: 1.4rem;
  margin: 0 0 0.5rem 0;
  color: var(--text-color);
}

.article-meta {
  display: flex;
  gap: 1rem;
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.article-excerpt {
  color: var(--text-light);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.read-more {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

.read-more:hover {
  color: var(--secondary-color);
}

.sidebar {
  width: 300px;
}

.sidebar-section {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.sidebar-section h3 {
  font-size: 1.2rem;
  margin: 0 0 1rem 0;
  color: var(--text-color);
}

.search-box {
  display: flex;
}

.search-box input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px 0 0 4px;
}

.search-box button {
  padding: 0.5rem 1rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
}

.category-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.category-list li {
  margin-bottom: 0.5rem;
}

.category-list a {
  color: var(--text-light);
  text-decoration: none;
  transition: var(--transition);
}

.category-list a:hover {
  color: var(--primary-color);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tags a {
  background: #f5f5f5;
  color: var(--text-light);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  text-decoration: none;
  font-size: 0.9rem;
  transition: var(--transition);
}

.tags a:hover {
  background: var(--primary-color);
  color: white;
}

.footer {
  background-color: var(--secondary-color);
  color: white;
  padding: 2rem 0;
  margin-top: auto;
}

.footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.social-links {
  display: flex;
  gap: 1rem;
}

.social-links a {
  color: white;
  text-decoration: none;
  transition: var(--transition);
}

.social-links a:hover {
  color: var(--primary-color);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .navbar .container {
    flex-direction: column;
    gap: 1rem;
  }
  
  .nav-links {
    justify-content: center;
  }
  
  .nav-links li {
    margin: 0 0.5rem;
  }
  
  main {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
  }
  
  .footer .container {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
}
</style>